﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace QMERP.Infrastructure.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init32 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "Type",
                table: "BulkOrder",
                type: "nvarchar(50)",
                maxLength: 50,
                nullable: false,
                defaultValue: "");

            migrationBuilder.CreateTable(
                name: "BulkOrderDetail_BifocalMaterialDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    EyeType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Base = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    BulkOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BulkOrderDetail_BifocalMaterialDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_BifocalMaterialDetail_BulkOrderDetail_BulkOrderDetailId",
                        column: x => x.BulkOrderDetailId,
                        principalTable: "BulkOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "BulkOrderDetail_MonofocalMaterialDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Diameter = table.Column<int>(type: "int", nullable: false),
                    Base = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    BulkOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BulkOrderDetail_MonofocalMaterialDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_MonofocalMaterialDetail_BulkOrderDetail_BulkOrderDetailId",
                        column: x => x.BulkOrderDetailId,
                        principalTable: "BulkOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_Type",
                table: "BulkOrder",
                column: "Type");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_BifocalMaterialDetail_BulkOrderDetailId",
                table: "BulkOrderDetail_BifocalMaterialDetail",
                column: "BulkOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_BifocalMaterialDetail_EyeType",
                table: "BulkOrderDetail_BifocalMaterialDetail",
                column: "EyeType");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_BifocalMaterialDetail_Id",
                table: "BulkOrderDetail_BifocalMaterialDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_MonofocalMaterialDetail_BulkOrderDetailId",
                table: "BulkOrderDetail_MonofocalMaterialDetail",
                column: "BulkOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_MonofocalMaterialDetail_Id",
                table: "BulkOrderDetail_MonofocalMaterialDetail",
                column: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "BulkOrderDetail_BifocalMaterialDetail");

            migrationBuilder.DropTable(
                name: "BulkOrderDetail_MonofocalMaterialDetail");

            migrationBuilder.DropIndex(
                name: "IX_BulkOrder_Type",
                table: "BulkOrder");

            migrationBuilder.DropColumn(
                name: "Type",
                table: "BulkOrder");
        }
    }
}
